<?php
class Module extends AppModel {
	var $name = 'Module';
	var $displayField = 'title';
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $belongsTo = array(
		'Dmdformtype' => array(
			'className' => 'Dmdformtype',
			'foreignKey' => 'dmdformtype_id',
		)
	);

        function getModulesForDmdformType($idType=null){
            if($idType){
                return $this->find('list',array(
                    'conditions'=>array(
                        'dmdformtype_id'=>$idType
                    ),
                    'order'=>array('position')
                ));
            }else{
                return false;
            }
        }
        function getModulesGetActionsForDmdformType($idType=null){
            if($idType){
                return $this->find('list',array(
                    'conditions'=>array(
                        'dmdformtype_id'=>$idType
                    ),
                    'fields'=>array('get_action'),
                    'order'=>array('position')
                ));
            }else{
                return false;
            }
        }
        function getModulesValidationForDmdformType($idType=null){
            if($idType){
                return $this->find('list',array(
                    'conditions'=>array(
                        'dmdformtype_id'=>$idType
                    ),
                    'fields'=>array('get_validation'),
                    'order'=>array('position')
                ));
            }else{
                return false;
            }
        }
        function getModuleTitleNames($idType=null){
            if($idType){
                return $this->find('list',array(
                    'conditions'=>array(
                        'dmdformtype_id'=>$idType
                    ),
                    'fields'=>array('menutitle'),
                    'order'=>array('position')
                ));
            }else{
                return false;
            }
        }

        function getModules($idtype){
            return $this->find('all',array(
                'recursive'=>-1,
                'order'=>array('position'),
                'conditions'=>array('dmdformtype_id'=>$idtype)
            ));
        }
    
}
?>